package com.lvandroid.player.activity;

import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.TextUtils;

import androidx.appcompat.app.AppCompatActivity;

import com.lvandroid.play.player.AllRoundPlayer;
import com.lvandroid.play.player.AllRoundPlayerManager;
import com.lvandroid.play.util.LogUtil;
import com.lvandroid.player.R;

public class AudioPlayerActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_audio_player);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Cursor c = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Video.Media.DATA}
                , null ,null, null);
        String path = null;
        if(null != c && c.moveToNext()) {
            path = c.getString(0);
            LogUtil.i("AudioPlayerActivity", "getVideoFile : " + path);
            c.close();
        }

        AllRoundPlayer player = AllRoundPlayerManager.createPlayer(AllRoundPlayerManager.MEDIA_TYPE_AUDIO);
        if(TextUtils.isEmpty(path))
            return;

        player.start(path);
    }
}